<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- DW6 -->
<head>
<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
<%@ page contentType="text/html; charset=utf-8"  language="java" import="java.util.*" pageEncoding="UTF-8" isELIgnored="false"%> 
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>


<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Insert title here</title>
<script src="<%=request.getContextPath()%>/js/jquery.min.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/js/jquery.uploadify.v2.1.4.min.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/js/swfobject.js" type="text/javascript"></script>
<link href="<%=request.getContextPath()%>/js/uploadify.css" rel="stylesheet" type="text/css" />


</head>
<body>
<form name="goodsinfo" action="<%=request.getContextPath()%>/admin/goodssave.do" method="post">
<table>
<tr>
<td><input type="button" value="保存" onclick="save()"/></td>
<td><input type="hidden" name="goodsid" value="${goods.id}" />
<input type="hidden" name="typeid" value="${typeid}" /></td>
</tr>
</table>
<table>
<tr>
<td>
  <table>
    <tr><td>名称:</td><td><input msg="名称" type=text id="goodsName" name="goodsName" value="${goods.goodsName}" /></td></tr>
    <tr><td>编号:</td><td><input msg="编号" type=text id="goodsNO" name="goodsNO" value="${goods.goodsNO}" /></td></tr>
    <tr><td>价格:</td><td><input msg="价格" type=text id="price" name="price" value="${goods.price}" /></td></tr>
    <tr><td>成本:</td><td><input msg="成本" type=text id="costprice" name="costprice" value="${goods.costPrice}" /></td></tr>
    <tr><td>库存:</td><td><input msg="库存" type=text id="goodsNum" name="goodsNum" value="${goods.goodsNum}" /></td></tr>
    <tr><td>排序:</td><td><input msg="排序" type=text id="sort" name="sort" value="${goods.sort}" /></td></tr>
     <tr><td>是否兑换:</td>
    <td><select id="ifScore" name="ifScore" />
       <option value="0" <c:if test="${goods.ifScore==0}">selected</c:if>>否</option>
       <option value="1" <c:if test="${goods.ifScore==1}">selected</c:if>>是</option>
    </td>
    </tr>
    <tr><td>兑换积分:</td><td><input msg="兑换积分" type=text  id="scorePrice"  name="scorePrice" value="${goods.scorePrice}" /></td></tr>
  </table>
</td>
<td>
<!--  
   <table>
    <tr><td>材质:</td><td><input type=text name="brand" value="${goods.brand}" /></td></tr>
    <tr><td>尺寸:</td><td><input type=text name="format" value="${goods.format}" /></td></tr>
    <tr><td>颜色:</td><td><input type=text name="color" value="${goods.color}" /></td></tr>
    <tr><td>描述1:</td><td><input type=text name="desc1" value="${goods.desc1}" /></td></tr>
    <tr><td>描述2:</td><td><input type=text name="desc2" value="${goods.desc2}" /></td></tr>
   </table>
-->
   <table>
   
    <tr><td>是否特价:</td>
     <td><select name="ifDiscount"  id="ifDiscount">
       <option value="0" <c:if test="${goods.ifDiscount==0}">selected</c:if>>否</option>
       <option value="1" <c:if test="${goods.ifDiscount==1}">selected</c:if>>是</option>
       </select>
     </td>
    </tr>
    <tr><td>原价:</td><td><input msg="原价" type=text name="historyPrice" id="historyPrice" value="${goods.historyPrice}" /></td></tr>
    <tr><td>是否显示:</td>
     <td><select name="status"  id="status">
       <option value="1" <c:if test="${goods.status==1}">selected</c:if>>是</option>
       <option value="0" <c:if test="${goods.status==0}">selected</c:if>>否</option>     
       </select>
     </td>
    </tr>
    <tr><td>品牌:</td><td><input msg="品牌" type=text name="brand" id="brand" value="${goods.brand}" /></td></tr>
    <tr><td>规格:</td><td><input msg="规格" type=text name="format" id="format" value="${goods.format}" /></td></tr>
    <tr><td>有效期:</td><td><input msg="有效期" type=text name="color" id="color" value="${goods.color}" /></td></tr>
    <tr><td>描述:</td><td><input msg="描述" type=text name="desc1" id="desc1" value="${goods.desc1}" /></td></tr>
   </table>
</td>
<td>
  <table>  
    <tr>
    <td>
    <img id="indexImg" src="<%=request.getContextPath()%>/goodsimages/${goods.id}/index.jpg" width="120px" height="120px"/>
    </td>
    </tr>
    <tr>
    <td align="center">首页缩略图</td><input type="hidden" name="imgNames" id="imgNames" value="${goods.imageUrl}"/>
    <td><input type="file" name="uploadify" id="uploadify"  /></td>
    </tr>
   </table>
</td>
</tr>
</table>
 <input type="hidden" name="bigimgname" id="bigimgname" />
</form>
<table>
<!--  
<tr>
<td colspan="3">
   <table>
    <tr id="groupimg" >
    <td id="temp" style="display:none" >
    <img src="<%=request.getContextPath()%>/"  width="80px" height="80px"/><br/>
    &nbsp&nbsp&nbsp<a class="pre" href="#" title="前移">&lt</a>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
    <a class="next" href="#" title="后移">&gt</a><br/><br/>
    &nbsp&nbsp&nbsp&nbsp<a class="delImg" href="#" >删除 </a> 
    </td>
   <c:forTokens var="str" items="${goods.imageUrl}" delims="," varStatus="status">
     <td id="${goods.id}" >
    <img src="<%=request.getContextPath()%>/goodsimages/${goods.id}/group/${fn:replace(str,'.','_big.')}"  width="80px" height="80px"/><br/>
    &nbsp&nbsp&nbsp<a class="pre" href="#" title="前移">&lt</a>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
    <a class="next" href="#" title="后移">&gt</a><br/><br/>
    &nbsp&nbsp&nbsp&nbsp<a class="delImg" href="#" >删除 </a> 
    </td>
    </c:forTokens>
   </tr>  
   </table>
 </td>
 </tr> 
-->        
 <tr>

 </tr>  
 <tr>
  <td><input type="file" name="biguploadify" id="biguploadify"  /></td>
  <td>
    <img id="bigImg" src="<%=request.getContextPath()%>/goodsimages/${goods.id}/big.jpg" width="150px" height="150px"/>
 </td>
</tr> 
</table>

   <div id="fileQueue"></div>
</body>
<script language="javascript"><!--
 function checkIsEmpty(id,name) {
 alert(document.getEletementById(id).value);
    if ( document.getEletementById(id).value=='') {
         alert(name+'不能为空');
         document.getEletementById(id).focus();
         return false;
    }
   }


  function save(){
    /**
     var imgNames="";
     var imgs=$("#groupimg").find("img");
     for(i=1;i<imgs.length;i++)
     {
        if(imgNames!="")
        {
        imgNames=imgNames+",";
        }
        imgNames=imgNames+imgs[i].href.substring(imgs[i].href.lastIndexOf("/")+1).replace("_big","");
     }
    $("#imgNames").attr("value",imgNames);
    **/
    var tempsrc=$("#indexImg").attr("src").replace('/', '\\').replace('/', '\\').replace('/', '\\');
    $("#imgNames").attr("value",tempsrc.substring(tempsrc.lastIndexOf("\\")+1));   
    var tempbig=$("#bigImg").attr("src").replace('/', '\\').replace('/', '\\').replace('/', '\\');
    $("#bigimgname").attr("value",tempbig.substring(tempbig.lastIndexOf("\\")+1));  
    if(checkNull())
    {
    document.goodsinfo.submit(); 
    }  
  }
  
  function checkNull()
{
     var num=0;
     var str="";
     $("input[type$='text']").each(function(n){
          if($(this).val()=="")
          {
               num++;
               str+="•"+$(this).attr("msg")+"不能为空！\r\n";
          }
     });
     if(num>0)
     {
          alert(str);
          return false;
     }
     else
     {
          return true;
     }
}

  /**
  function delImg(){   
     if($(this).parent().index()==1)
       {
         $("#indexImg").attr("src",$(this).parent().next().find("img").attr("src"));
       }
        $(this).parent().remove();
  }
  
  function pre(){
      if($(this).parent().index()>1)
      {      
       var cur=$(this).parent().find("img");
       var pre=$(this).parent().prev().find("img");
       var temp=pre.attr("src");
       pre.attr("src",cur.attr("src"));
       cur.attr("src",temp);
       if(pre.parent().index()==1)
       {
         $("#indexImg").attr("src",pre.attr("src"));
       }
      }    
  }
  
    function next(){
      if($(this).parent().index()<$(this).parent().parent().children().length-1)
      {      
       var cur=$(this).parent().find("img");
       var next=$(this).parent().next().find("img");
       var temp=next.attr("src");
       next.attr("src",cur.attr("src"));
       cur.attr("src",temp);
       if(cur.parent().index()==1)
       {
         $("#indexImg").attr("src",cur.attr("src"));
       }
      }    
  }
  **/      
$(document).ready( function() {
   $("#uploadify").uploadify( {//初始化函数

    'uploader' :'../js/uploadify.swf',//flash文件位置，注意路径
    'script' :'<%=request.getContextPath()%>/admin/imgUpload.do',//后台处理的请求
    'cancelImg' :'../js/cancel.png',//取消按钮图片
    'folder' :'uploads',//您想将文件保存到的路径
    'queueID' :'fileQueue',//与下面的上传文件列表id对应
    'queueSizeLimit' :1,//上传文件的数量
    'scriptData':{'goodsid':'${goods.id}'},//向后台传的数据
    'fileDesc' :'jpg、png和gif文件',//上传文件类型说明
    'fileExt' :'*.jpg;*.jpeg;*.png;*.gif', //控制可上传文件的扩展名，启用本项时需同时声明fileDesc
    'method':'post',//如果向后台传输数据，必须是get
    'sizeLimit':10000000,//文件上传的大小限制，单位是字节
    'auto' :true,//是否自动上传
    'multi' :true,
    'simUploadLimit' :1,//同时上传文件的数量
    //'buttonText' :'上传',//浏览按钮图片
    'onComplete': function(event, queueID, fileObj,response,data) {//当上传完成后的回调函数，ajax方式哦~~
       //var newImg= $("#temp").clone();
       //newImg.css("display","block");
      // var img=newImg.find("img");
       //var base=img.attr("src");
       ///img.attr("src",base+response); 
       $("#indexImg").attr("src","<%=request.getContextPath()%>"+"\\"+response); 
      // newImg.appendTo($("#groupimg"));
       //删除操作      
      // newImg.find("a.delImg").bind('click',delImg);
      // newImg.find("a.pre").bind('click',pre);
       //newImg.find("a.next").bind('click',next);
    }
   });
   
  //  $("#groupimg").find("a.delImg").bind('click',delImg);
  //  $("#groupimg").find("a.pre").bind('click',pre);
   // $("#groupimg").find("a.next").bind('click',next);
   
   
   
   
    $("#biguploadify").uploadify( {//初始化函数

    'uploader' :'../js/uploadify.swf',//flash文件位置，注意路径
    'script' :'<%=request.getContextPath()%>/admin/imgUpload.do',//后台处理的请求
    'cancelImg' :'../js/cancel.png',//取消按钮图片
    'folder' :'uploads',//您想将文件保存到的路径
    'queueID' :'fileQueue',//与下面的上传文件列表id对应
    'queueSizeLimit' :1,//上传文件的数量
    'scriptData':{'goodsid':'${goods.id}'},//向后台传的数据
    'fileDesc' :'jpg、png和gif文件',//上传文件类型说明
    'fileExt' :'*.jpg;*.jpeg;*.png;*.gif', //控制可上传文件的扩展名，启用本项时需同时声明fileDesc
    'method':'post',//如果向后台传输数据，必须是get
    'sizeLimit':10000000,//文件上传的大小限制，单位是字节
    'auto' :true,//是否自动上传
    'multi' :true,
    'simUploadLimit' :1,//同时上传文件的数量
    //'buttonText' :'上传',//浏览按钮图片
    'onComplete': function(event, queueID, fileObj,response,data) {//当上传完成后的回调函数，ajax方式哦~~
       //var newImg= $("#temp").clone();
       //newImg.css("display","block");
      // var img=newImg.find("img");
       //var base=img.attr("src");
       ///img.attr("src",base+response); 
       $("#bigImg").attr("src","<%=request.getContextPath()%>"+"\\"+response); 
      // newImg.appendTo($("#groupimg"));
       //删除操作      
      // newImg.find("a.delImg").bind('click',delImg);
      // newImg.find("a.pre").bind('click',pre);
       //newImg.find("a.next").bind('click',next);
    }
   });
});


        
--></script>
</html>

